//
//  UpdateFieldViewController.m
//  edu
//
//  Created by baobaodp on 13-11-20.
//  Copyright (c) 2013年 baobaodp. All rights reserved.
//

#import "UpdateFieldViewController.h"

@interface UpdateFieldViewController ()

@end

@implementation UpdateFieldViewController

//字段编辑框
@synthesize txtFieldInput;
@synthesize updateFieldDelegate;
@synthesize fieldName;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //初期值
    self.txtFieldInput.text = self.primaryValue;
    
    //默认获得焦点 弹出软键盘
    [self.txtFieldInput becomeFirstResponder];
    
    //返回按钮
    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(doUpdate)];
    self.navigationItem.leftBarButtonItem = backButton;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



-(void) doUpdate
{
    [[self navigationController] popViewControllerAnimated:YES];
    
    if([self.txtFieldInput.text isEqualToString:self.primaryValue]){
        return;
    }
    
    //更新字段
    [self.updateFieldDelegate upDataField:self.fieldName value: self.txtFieldInput.text];
}

@end
